{include file="public/header-static"/}
{include file="public/sidebar"/}
<div id="main">
    {include file="public/header"/}
    <main class="main-content">
        <div class="container">
            <div class="page-header">
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item">
                            <a href="#">首页</a>
                        </li>
                        <li class="breadcrumb-item active" aria-current="page">涨知识修改</li>
                    </ol>
                </nav>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <div class="card">
                        <div class="card-body">
                            <form action="{$form}" method="post" target="iframe_form" enctype="multipart/form-data">

                                <input type="hidden" name="id" class="form-control" value="{$info.id}">
                                <input type="hidden" name="types" value="{$source}">

                                <div class="form-group row">
                                    <label class="col-sm-1 col-form-label">分类</label>
                                    <div class="input-group col-sm-8">
                                        <select class="form-control my_cids" name="cids" aria-required="true"
                                                style="width:37.5%;line-height:35px">
                                            <option value="">请选择分类</option>

                                            {volist name="topCate" id="vo"}
                                            <option value="{$vo.id}" {if $info.cids== $vo.id}selected{/if}>{$vo.name}</option>
                                            {/volist}

                                        </select>
                                    </div>
                                </div>

                                <div class="form-group row">
                                    <input type="hidden" name="data_type" value="1">
                                    <label for="" class="col-sm-1 col-form-label">社群ID</label>
                                    <div class="col-sm-8">
                                        <input type="text" name="rid" class="form-control" placeholder="社群ID"
                                               value="{$info.rid}">
                                    </div>
                                </div>

                                <div class="form-group row" style="display: none">
                                    <label for="" class="col-sm-1 col-form-label">顾问ID</label>
                                    <div class="col-sm-8">
                                        <input type="text" value="{$info.aid}" name="aid" class="form-control"
                                               placeholder="顾问ID">
                                    </div>
                                </div>

                                <div class="form-group row">
                                    <label for="" class="col-sm-1 col-form-label">标题</label>
                                    <div class="col-sm-8">
                                        <input type="text" name="title" class="form-control" placeholder="标题"
                                               value="{$info.title}">
                                    </div>
                                </div>

                                <!--                                <div class="form-group row">-->
                                <!--                                    <label for="" class="col-sm-1 col-form-label">费用</label>-->
                                <!--                                    <div class="col-sm-8">-->
                                <!--                                        <input type="text" name="money"  class="form-control"  placeholder="费用（是否收费，不填默认免费）" value="{$info.money}">-->
                                <!--                                    </div>-->
                                <!--                                </div>-->

                                <div class="form-group row">
                                    <label class="col-sm-1 col-form-label">封面图</label>
                                    <div class="col-sm-4">
                                        <input type="hidden" class="form-control cover" name="cover" required=""
                                               aria-required="true" value="{$info.cover}">
                                        <button type="button" class="btn btn-secondary" id="cover">上传封面</button>
                                        <span style="color: #6c757d">&nbsp;（ 尺寸建议：228 * 148 ）</span>

                                        <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                            预览图：
                                            <div class="layui-upload-list uploader-list" style="overflow: auto;"
                                                 id="uploader-cover">

                                                <div class="file-iteme original">
                                                    <div class="handle" src="{$info.cover}">
                                                        <span class="fa fa-times"
                                                              style="border-radius: 0.375rem 0.375rem 0 0;"></span>
                                                    </div>
                                                    <img style="width: 5rem;height: 5rem;border-radius: 0.375rem;"
                                                         src="{$info.ycover}">
                                                </div>


                                            </div>
                                        </blockquote>
                                    </div>
                                </div>

                                <div class="form-group row">
                                    <label class="col-sm-1 col-form-label">详情</label>
                                    <div class="col-sm-8">
                                        <textarea placeholder="详情" id="containers" name="content" type="text/plain"
                                                  style="">{$info.content}</textarea>
                                    </div>
                                </div>

                                <div class="form-group row">
                                    <label for="" class="col-sm-1 col-form-label">发布人</label>
                                    <div class="col-sm-8">
                                        <select name="enroll_id" id="enroll_id" class="form-control">
                                            <option value="">请选择发布人</option>
                                            {volist name="officialStaff" id="vo"}
                                            <option value="{$vo.id}" {if $vo.id== $info.enroll_id}selected{/if}>{$vo.alias}</option>
                                            {/volist}
                                        </select>
                                    </div>
                                </div>
                                <button type="submit" class="btn btn-secondary">提交</button>
                            </form>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </main>

    {include file="public/footer"/}

    <!-- 配置文件 -->
    <script type="text/javascript" src="__STATIC__/assets/js/plugins/ueditor/ueditor.config.js"></script>
    <!-- 编辑器源码文件 -->
    <script type="text/javascript" src="__STATIC__/assets/js/plugins/ueditor/ueditor.all.js"></script>

    <script>

        // 实例化编辑器  http://fex.baidu.com/ueditor/#start-toolbar
        var ue = UE.getEditor('containers', {
            toolbars: [
                [
                    'undo', //撤销
                    'redo', //重做
                    'bold', //加粗
                    'indent', //首行缩进
                    'italic', //斜体
                    'underline', //下划线
                    'strikethrough', //删除线
                    'subscript', //下标
                    'fontborder', //字符边框
                    'superscript', //上标
                    'formatmatch', //格式刷
                    'blockquote', //引用
                    'selectall', //全选
                    'horizontal', //分隔线
                    'removeformat', //清除格式
                    'time', //时间
                    'date', //日期
                    'fontfamily', //字体
                    'fontsize', //字号
                    'paragraph', //段落格式
                    'simpleupload', //单图上传
                    'insertimage', //多图上传
                    'emotion', //表情
                    'spechars', //特殊字符
                    'insertvideo', //视频
                    'justifyleft', //居左对齐
                    'justifyright', //居右对齐
                    'justifycenter', //居中对齐
                    'justifyjustify', //两端对齐
                    'forecolor', //字体颜色
                    'backcolor', //背景色
                    'insertorderedlist', //有序列表
                    'insertunorderedlist', //无序列表
                    'rowspacingtop', //段前距
                    'rowspacingbottom', //段后距
                    'touppercase', //字母大写
                    'tolowercase', //字母小写
                    'background', //背景
                    'scrawl', //涂鸦
                ]
            ],
            initialFrameHeight: 350,
            initialFrameWidth: "100%"
        });

        // 各种上传
        layui.use('upload', function () {
            var $ = layui.jquery
                , upload = layui.upload;

            // 封面图上传
            upload.render({
                elem: '#cover'
                , accept: 'images'
                , acceptMime: 'image/*'
                , url: '{:url("/console/imageReturn")}?path=loreCover'
                , before: function (obj) {
                    layer.msg('封面图上传中...', {
                        icon: 16,
                        shade: 0.05,
                        time: 0
                    });
                }
                , done: function (res) {
                    layer.close(layer.msg());//关闭上传提示窗口
                    // console.log(res)
                    //上传完毕
                    var cover = $('.cover').val();
                    if (cover != '') {
                        // 删除旧图片
                        var element = $('#uploader-cover').children('.file-iteme');
                        if (!element.is('.original')) {
                            console.log('不是原封面数据，删除');
                            delImageOrVideo(cover);
                        }
                        element.remove();
                    }
                    $('.cover').val(res.data.src);
                    $('#uploader-cover').append(
                        '<div id="" class="file-iteme">' +
                        '<div class="handle" src="' + res.data.src + '"><span class="fa fa-times" style="border-radius: 0.375rem 0.375rem 0 0;"></span></div>' +
                        '<img style="width: 5rem;height: 5rem;border-radius: 0.375rem;" src=' + res.data.src + '>' +
                        // '<div class="info">' + res.data.name + '</div>' +
                        '</div>'
                    );
                }
            });

        });

        // 删除图片
        $(document).on("click", ".file-iteme .handle", function (event) {
            console.log($(this).attr('src'), $(this), $(this).parents().eq(3).children().eq(0))

            var inputVal = $(this).parents().eq(3).children().eq(0);
            console.log(inputVal)
            if (inputVal.val() != '') {
                inputVal.val('');
            }

            $(this).parent().remove();
        });

    </script>


</div>